package model.posterminal;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import model.BaseObject;

import org.simpleframework.xml.*;

/**
 * Class describes posterminal model
 * @author Potseluev
 *
 */
@Root(name = "posterminalmodel")
public class PosterminalModel  extends BaseObject implements Serializable{
	

	@Element(name = "posterminalproducer", required = false)
	PosterminalProducer posterminalProducer;
	
	@Element(name = "posterminalmodelname", required = false)
	String posterminalModelName;
	
	// *** fields end ***
	
	public String getPosterminalModelName() {
		return posterminalModelName;
	}

	public void setPosterminalModelName(String posTerminalModelName) {
		this.posterminalModelName = posTerminalModelName;
	}

	public PosterminalProducer getPosterminalProducer() {
		return posterminalProducer;
	}

	public void setPosterminalProducer(PosterminalProducer posterminalProducer) {
		this.posterminalProducer = posterminalProducer;
	}

	//*** getters and setters ends
	
	@Override
	protected void setStoredProcedureName() {
		this.selectStoreProcedureName = "selectPosterminalModel";
		this.insertStoreProcedureName = "insertPosterminalModel";
		this.updateStoreProcedureName = "updatePosterminalModel";
		this.deleteStoreProcedureName = "deletePosterminalModel";
		
	}
	
	/**
	 * Load all exist PosTerminalModel
	 * @return
	 * @throws Exception
	 */
	public List<PosterminalModel> getAllPosterminalModel() throws Exception {
		return (ArrayList<PosterminalModel>) this.selecttObjectList(null);
	}
	
	public List<PosterminalModel> getPosterminalModelByProducer(PosterminalProducer producer) throws Exception {
		return (ArrayList<PosterminalModel>) this.selecttObjectList(producer);
	}

    // This must return true for another class object with same id.
    public boolean equals(Object other) {
        return other instanceof PosterminalModel && (this.id != null) ? this.id.equals(((PosterminalModel) other).getId()) : (other == this);
    }

    // This must return the same hashcode for every class object with the same id.
    public int hashCode() {
        return this.id != null ? this.getClass().hashCode() + this.id.hashCode() : super.hashCode();
    }
    
}
